#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#define HASH_SIZE 1000  
typedef struct daolu{
    int quxiangid;        
    int length;           
    int time1;    //原始时间
    int time2;    //受事件影响后的时间
    int max;      
    struct daolu *next;    
} daolu;

typedef struct lukou{
    int id;               
    int liuliang;            
    daolu *adj;            
} lukou;

typedef struct Event {
    int id;               
    char type[50];        
    int road_id;          
    time_t start_time;    
    time_t end_time;      
    struct Event *next;   
} Event;

typedef struct HashNode {
    int key;              
    lukou *vertex;       
    struct HashNode *next;
} HashNode;

HashNode *hash_table[HASH_SIZE];




typedef struct Queue {
    Event *front;         // 队首
    Event *rear;          // 队尾
} Queue;
// 初始化图（路口）
void init_graph(lukou *vertices, int n) {
    for (int i = 0; i < n; i++) {
        vertices[i].id = i;
        vertices[i].liuliang = 0;
        vertices[i].adj = NULL;
    }
}
int genshin(){
    return 0;
}


    count_flow(vertices, n);
    heap_sort(vertices, n);
    printf("=== 流量排序（降序）===\n");
    for (int i = 0; i < n; i++) 
        printf("路口%d: 流量%d\n", vertices[i].id, vertices[i].flow);

    // 6. 测试事件队列（模拟施工事件）
    Event *e = (Event*)malloc(sizeof(Event));
    e->id = 1;
    strcpy(e->type, "施工");
    e->road_id = 0; // 假设影响0->1的边
    e->start_time = time(NULL);
    e->end_time = e->start_time + 3600; // 1小时后恢复
    enqueue(&queue, e);
    
 int length;         
    int time1;     
    int time2;  
    int carmax; 
    int currentcar;
typedef struct luko{
    int id;
    char name[namelength]; 
    struct luko* next;
}luko;
typedef struct jiaotongtu{
    int lukonum;      
    lu lu[lukomax][lukomax]; 
}jiaotongtu;
typedef struct Event{
    int eventid;     
    int lukoid;    
    int* yinxiangroad; 
    int yinxiangnum;     
    time_t starttime;   
    time_t endtime;    
}Event;
typedef struct EventNode {
    Event event;
    struct EventNode* next;
} EventNode;
nsigned int hash(int key) {
    return key %hashsize;
}

// 哈希表插入（带名称输入）
void hashinsert(luko* node) {
    if (!node) return;
    unsigned int idx = hash(node->id);
    node->next = hash_table[idx];
    hash_table[idx] = node;
}

// 哈希表查找
luko* hashsearch(int key) {
    unsigned int idx = hash(key);
    luko* p = hash_table[idx];
    while (p != NULL) {
        if (p->id == key) return p;
        p = p->next;
    }
    return NULL;
}